﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" Title="猎书网-用户登录" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script language="javascript" src="/model/jquery.validate.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){    
  $.validator.setDefaults({    
  submitHandler: function(form) { 
    $.ajax({ url: 'Login.aspx',
            type: 'POST',
            data: { lb: "login", username: $("#username").val(),password:$("#password").val(),confirm:$("#confirm").val()},
            dataType: 'html',
            timeout: 1000,
            error: function() { alert('未知错误'); },
            success: function(data) { 
             if(data=="登录成功"){
                 window.location="MyBook.aspx";
              }
              else{
                window.alert(data);
              }              
            }
            }); 
    }    //end of submitHandler
  });  // end of setDefaults
  
  $(myForm).validate({    
/* 设置验证规则 */    
  rules: {    
    username: {    
    required: true
   },    
   password: {    
    required: true 
   },
   confirm:{
    required:true,
    minlength:4,
    maxlength:4
   }
  },    
/* 设置错误信息 */    
  messages: {    
   username: {    
    required: "请填写用户名"
   },    
   password: {    
    required: "请填写密码"
   },  
   confirm:{
    required:"请输入验证码",
    minlength: "验证码为4位的",
    maxlength:"验证码是4位的"
   } 
  },    
/* 错误信息的显示位置 */    
  errorPlacement: function(error, element) {    
    error.appendTo( element.parent() );      
  },    
  success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
});

//增加注册按钮事件
$("#register").bind("click", function(e){
      window.location="Register.aspx";
    });
  
});  
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<form id="myForm" action="#">
  <table cellspacing="0" cellpadding="0" class="myTable myFormTable">
        <tr >
      <td colspan="2" style="color:red;background-color:white"> 
          对不起，您尚未登陆!（由于服务器负载过大，投票、广告清理、书籍目录自主检索等等功能只对注册登录用户开放，强烈推荐使用“清风小说浏览器”访问本站）</td>
    </tr>
    <tr>
      <td colspan="2" class="title"> 用户登陆</td>
    </tr>
    <tr>
      <th width="25%">用户名：</th>
      <td width="75%"><input name="username" type="text" id="username" /></td>
    </tr>
    <tr>
      <th>输密码：</th>
      <td><input name="password" type="password" id="password" /> 
          2009/10/24日前注册的用户，密码已经初始化为123456</td>
    </tr>
    <tr>
    <th>验证码：</th>
      <td ><input name="confirm" type="text" id="confirm" style="width:50px;" />
      <asp:Image Runat="server" ID="ImageCheck" ImageUrl="ValidateCode.aspx"></asp:Image>
      </td>
    </tr>
  </table>
  <div><input type="submit" name="login" value="登陆" id="login"/><input type="button" name="register" value="注册" id="register"/></div>
</form>
</asp:Content>

